<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Clearsign text</title>
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-base.css" />
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-medium.css" />

 </head>
 <body class="docs"><div class="navbar navbar-fixed-top">
  <div class="navbar-inner clearfix">
    <ul class="nav" style="width: 100%">
      <li style="float: left;"><a href="rnp.examples.html">« 范例</a></li>
      <li style="float: right;"><a href="ref.rnp.html">Rnp 函数 »</a></li>
    </ul>
  </div>
</div>
<div id="breadcrumbs" class="clearfix">
  <ul class="breadcrumbs-container">
    <li><a href="index.html">PHP Manual</a></li>
    <li><a href="rnp.examples.html">范例</a></li>
    <li>Clearsign text</li>
  </ul>
</div>
<div id="layout">
  <div id="layout-content"><div id="rnp.examples-clearsign" class="section">
  <h2 class="title">Clearsign text</h2>
  <p class="para">
   This example will clearsign a given text.
  </p>
  <div class="example" id="example-972">
   <p><strong>示例 #1 RNP clearsign example</strong></p>
   <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /></span><span style="color: #FF8000">//&nbsp;init&nbsp;FFI&nbsp;object<br /></span><span style="color: #0000BB">$ffi&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">rnp_ffi_create</span><span style="color: #007700">(</span><span style="color: #DD0000">'GPG'</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'GPG'</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">//&nbsp;generate&nbsp;RSA&nbsp;key<br /></span><span style="color: #0000BB">$key&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">rnp_op_generate_key</span><span style="color: #007700">(</span><span style="color: #0000BB">$ffi</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'test@example.com'</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'RSA'</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">//&nbsp;sign<br /></span><span style="color: #0000BB">$data&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">"Example&nbsp;text&nbsp;to&nbsp;sign"</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$signature&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">rnp_op_sign_cleartext</span><span style="color: #007700">(</span><span style="color: #0000BB">$ffi</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$data</span><span style="color: #007700">,&nbsp;array(</span><span style="color: #0000BB">$key</span><span style="color: #007700">));<br /><br />echo&nbsp;</span><span style="color: #0000BB">$signature</span><span style="color: #007700">;<br /><br /></span><span style="color: #FF8000">//&nbsp;destroy&nbsp;FFI&nbsp;object<br /></span><span style="color: #0000BB">rnp_ffi_destroy</span><span style="color: #007700">(</span><span style="color: #0000BB">$ffi</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
   </div>

  </div>
 </div></div></div></body></html>